Package edu.claflin.finder.logic.comp
Class EdgeWeightComparator
java.lang.Object
edu.claflin.finder.logic.comp.EdgeWeightComparator
- All Implemented Interfaces:
Comparator<Edge>
A simple edge weight comparator in which the edge data is considered a
numeric value and used as the comparison benchmark.
- Version:
- 3.0 February 4, 2016
- Author:
- Charles Allen Schultz II
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanIndicates if the comparator should sort elements in ascending order. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
ascending
private final boolean ascendingIndicates if the comparator should sort elements in ascending order.
-
-
Constructor Details
-
EdgeWeightComparator
public EdgeWeightComparator(boolean ascending) Constructs an EdgeWeightComparator.- Parameters:
ascending- boolean indicating if edges should be sorted in ascending order.
-
-
Method Details
-
compare
Compares the edges based on the D data held by the edge. Assumes the data is a numeric value.- Specified by:
comparein interfaceComparator<Edge>- Parameters:
e1- the first edge to compare.e2- the second edge to compare.- Returns:
- -1, 0, or 1 if the first edge is ordered before, the same as, or after the second.
-